﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using OgilvyOne.Model;
using OgilvyOne.BLL;
public partial class admin_allergy_dotcor_img_detail : System.Web.UI.Page
{
    public string doctorId;
    protected void Page_Load(object sender, EventArgs e)
    {
        doctorId = Request["id"].ToString();
        if (!IsPostBack)
        {
            try
            {
                if (Request.Params["imgId"].ToString() != null && Request.Params["imgId"].ToString() != "")
                {
                    DataTable dt = BLLArticleInfo.selImg("imgId", Request.Params["imgId"].ToString());
                    foreach (DataRow row in dt.Rows)
                    {
                        this.imgesId.Value = row["imgId"].ToString();
                        this.img_name.Text = row["imgName"].ToString();
                        this.img_file_name.Value = row["imgFileName"].ToString();
                        this.img_order.Text = row["imgOrder"].ToString();
                        this.typelist.SelectedValue = row["imgType"].ToString();
                        this.state.SelectedValue = row["status"].ToString();
                        this.img_file_name.Value = row["imgFileName"].ToString();
                    }

                }
            }
            catch (Exception)
            { }
        }
    }
    protected void Sub_click(object sender, EventArgs e)
    {
        nestle_doctor_img info=new nestle_doctor_img();
        info.ImgName = this.img_name.Text.ToString();
        info.ImgFileName = this.img_file_name.Value.ToString();
        info.ImgOrder = this.img_order.Text.ToString();
        info.ImgType = this.typelist.SelectedValue.ToString();
        info.DoctorId = doctorId;
        info.Status = this.state.SelectedValue.ToString();


        if (this.imgesId.Value != null && this.imgesId.Value != "")
        {
            BLLArticleInfo.UpdataImg(info,this.imgesId.Value);
        }
        else
        {
            BLLArticleInfo.InsertImg(info);
        }
        
        
        if (this.typelist.SelectedValue == "0")
        {
            BLLArticleInfo.upImg("columnphoto", info.ImgFileName, doctorId);
        }
        if (this.typelist.SelectedValue == "1")
        {
            BLLArticleInfo.upImg("indexphoto", info.ImgFileName, doctorId);
        }
        Response.Redirect("doctor_img_list.aspx?id=" + doctorId);
    }
}
